package com.example.demo.Service;

import catcode.CatCodeUtil;
import catcode.CodeTemplate;
import com.example.demo.entity.GetMsgVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class ApiService {
    @Autowired
    RestTemplate restTemplate;

    public String getDay(GetMsgVo getMsgVo)
    {
        String url="http://api.wpbom.com/api/daygas.php?msg=";
        if (getMsgVo.getUserGet()==null)
        {
           url+=getMsgVo.getUserSet()+"&b=1";
        }else
        {
            url+=getMsgVo.getUserSet()+"&b="+getMsgVo.getUserGet();
        }
        return restTemplate.getForObject(url,String.class);
    }
    public String userTranslate(GetMsgVo getMsgVo)
    {
        String url="http://api.wpbom.com/api/trans.php?msg="+getMsgVo.getUserSet();
        return restTemplate.getForObject(url,String.class);
    }

    public String getImg(GetMsgVo getMsgVo)
    {

        String url="http://api.wpbom.com/api/picture.php?msg=";
        if (getMsgVo.getUserSet()==null)
        {
            url+="游戏";
        }
        else {
            url+=getMsgVo.getUserSet();
        }
        restTemplate.getForObject(url,String.class);

        return "[CAT:image,file=http://p3.qhimg.com/bdm/1280_800_85/t01d7f5f8c1c81ae9ce.jpg]";
    }
}
